<template>
  <div class="main">
    <div class="center">
      <div class="info">
        <div class="lf">
          <el-image lazy :src="musicCollectionData.image" alt="" srcset="" />
        </div>
        <div class="rt">
          <div class="row">
            <div class="title">专辑名称</div>
            <div class="dian">：</div>
            <div class="text" v-html="musicCollectionData.name"></div>
          </div>
          <div class="row">
            <div class="title">流派</div>
            <div class="dian">：</div>
            <div class="text">{{ musicCollectionData.style }}</div>
          </div>
          <div class="row">
            <div class="title">语种</div>
            <div class="dian">：</div>
            <div class="text">{{ musicCollectionData.language }}</div>
          </div>
          <div class="row">
            <div class="title">发行时间</div>
            <div class="dian">：</div>
            <div class="text">{{ musicCollectionData.show_time }}</div>
          </div>
          <div class="row">
            <div class="title">唱片公司</div>
            <div class="dian">：</div>
            <div class="text">{{ musicCollectionData.company }}</div>
          </div>
          <div class="row">
            <div class="title">时长</div>
            <div class="dian">：</div>
            <div class="text">{{ musicCollectionData.duration }}</div>
          </div>
          <div class="row">
            <div class="title">简介</div>
            <div class="dian">：</div>
            <div class="text" v-html="musicCollectionData.detail"></div>
          </div>
        </div>
        <div class="qr-code">
          <el-image lazy :src="musicCollectionData.code_url" alt="" srcset="" />
          <p>用手机观看</p>
        </div>
      </div>
      <div class="single">
        <div
          class="item"
          v-for="(item, index) in musicCollectionData.music"
          :key="index"
        >
          <div class="column">
            <div class="title">歌曲:</div>
            <div class="cont">{{ item.name }}</div>
            <div class="tag" v-if="item.mv != null">MV</div>
          </div>
          <div class="column">
            <div class="title">歌手:</div>
            <div class="cont">{{ item.singer }}</div>
          </div>
          <div class="column">
            <div class="title">专辑:</div>
            <div class="cont">{{ item.collection }}</div>
          </div>
          <div class="column">
            <div class="title">时长:</div>
            <div class="cont">{{ item.duration }}</div>
          </div>
          <div class="column">
            <div class="title">歌词:</div>
            <router-link
              :to="{ name: 'single', query: { id: item.id } }"
              class="view-btn"
              >查看</router-link
            >
          </div>
          <div class="column">
            <a
              v-if="
                item.url_1 != null &&
                item.url_1 != '' &&
                item.url_1 != 'None' &&
                item.url_1 != undefined
              "
              class="img"
              :href="item.url_1"
              target="_blank"
              rel="noopener noreferrer"
            >
              <el-image
                lazy
                :src="require('../assets/images/qq.png')"
                alt=""
                srcset=""
            /></a>
            <a
              v-if="
                item.url_2 != null &&
                item.url_2 != '' &&
                item.url_2 != 'None' &&
                item.url_2 != undefined
              "
              class="img"
              :href="item.url_2"
              target="_blank"
              rel="noopener noreferrer"
            >
              <el-image
                lazy
                :src="require('../assets/images/kg.png')"
                alt=""
                srcset=""
            /></a>
            <a
              v-if="
                item.url_3 != null &&
                item.url_3 != '' &&
                item.url_3 != 'None' &&
                item.url_3 != undefined
              "
              class="img"
              :href="item.url_3"
              target="_blank"
              rel="noopener noreferrer"
            >
              <el-image
                lazy
                :src="require('../assets/images/wyy.png')"
                alt=""
                srcset=""
            /></a>
            <a
              v-if="
                item.url_4 != null &&
                item.url_4 != '' &&
                item.url_4 != 'None' &&
                item.url_4 != undefined
              "
              class="img"
              :href="item.url_4"
              target="_blank"
              rel="noopener noreferrer"
            >
              <el-image
                lazy
                :src="require('../assets/images/kw.png')"
                alt=""
                srcset=""
            /></a>
          </div>
        </div>
      </div>
      <!-- 加载更多 -->
      <!-- <div class="more-btn">加载更多</div> -->
    </div>
    <!-- 广告 -->
    <div class="ad">
      <a
        target="_blank"
        class="item"
        :href="item.url"
        v-for="(item, index) in adData.slice(0, 5)"
        :key="index"
      >
        <el-image lazy :src="item.image_mini" alt="" />
      </a>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      musicCollectionData: [],
      adData: [],
    };
  },
  created() {
    const id = this.$route.query.id;
    this.getMusicCollection(id);
    // 广告
    this.$http.getAd().then((res) => {
      if (res.data.code === 0) {
        this.adData = res.data.data;
      } else {
        this.$message.error("获取失败，请重试！");
      }
    });
  },
  methods: {
    getMusicCollection(id) {
      let data = {
        collection_id: id,
      };
      this.$http.getMusicCollection(data).then((res) => {
        if (res.data.code === 0) {
          this.musicCollectionData = res.data.data;
        } else {
          this.$message.error("获取失败，请重试！");
        }
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.center {
  width: 1600px;
  margin: 0 auto;
  .info {
    display: flex;
    justify-content: space-between;
    margin-top: 76px;
    position: relative;
    .lf {
      width: 400px;
      height: 550px;
      box-shadow: 0px 6px 10px rgba(0, 0, 0, 0.5);
      .el-image {
        width: 100%;
        height: 100%;
      }
    }
    .rt {
      width: 1160px;
      .row {
        display: flex;
        font-size: 20px;
        font-family: PingFang SC;
        font-weight: 400;
        line-height: 28px;
        .title {
          width: 130px;
          text-align-last: justify;
          text-align: justify;
          text-justify: distribute-all-lines;
          color: #999999;
        }
        .dian {
          color: #999999;
        }
        .text {
          width: 935px;
          margin-left: 10px;
          color: #333333;
        }
      }
      .row:not(:first-child) {
        margin-top: 20px;
      }
      .row:not(:last-child) .text {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
      .row:last-child .text {
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 6;
        overflow: hidden;
      }
    }
    .play-btn {
      position: absolute;
      top: 0;
      right: 280px;
      width: 200px;
      height: 48px;
      border: 2px solid #333333;
      border-radius: 4px;
      font-size: 20px;
      font-family: PingFang SC;
      font-weight: 400;
      line-height: 48px;
      text-align: center;
      color: #333333;
      cursor: pointer;
    }
    .qr-code {
      position: absolute;
      top: 0;
      right: 120px;
      width: 120px;
      text-align: center;
      img {
        width: 92px;
        height: 92px;
      }
      p {
        width: 120px;
        height: 28px;
        font-size: 20px;
        font-family: PingFang SC;
        font-weight: bold;
        line-height: 28px;
        color: #333333;
        text-align: center;
        margin-top: 8px;
      }
    }
  }
  .single {
    margin-top: 30px;
    .item {
      display: flex;
      margin-bottom: 20px;
      .column {
        font-size: 20px;
        font-family: PingFang SC;
        font-weight: 400;
        display: flex;
        align-items: center;
        height: 40px;
        .title {
          color: #999999;
          margin-right: 10px;
          width: 54px;
        }
        .cont {
          color: #333333;
          width: 180px;
          overflow: hidden;
          white-space: nowrap;
          text-overflow: ellipsis;
        }
        .tag {
          width: 40px;
          height: 20px;
          line-height: 20px;
          border: 1px solid #ff8000;
          border-radius: 2px;
          color: #ff8000;
          font-size: 12px;
          font-weight: 400;
          text-align: center;
          position: relative;
          top: -6px;
          left: 5px;
        }
        .view-btn {
          line-height: 20px;
          padding: 2px 8px;
          border: 1px solid #666666;
          border-radius: 4px;
          text-align: center;
          font-size: 20px;
          font-family: PingFang SC;
          font-weight: 400;
          color: #666666;
          cursor: pointer;
        }
        .img {
          cursor: pointer;
          width: 38px;
          height: 38px;
          img {
            width: 100%;
            height: 100%;
          }
        }
        .img:not(:last-child) {
          margin-right: 30px;
        }
      }
      .column:first-child {
        align-items: flex-end;
      }
      .column:not(:last-child) {
        margin-right: 30px;
      }
    }
  }
}
.ad {
  position: fixed;
  top: 150px;
  right: 100px;
  z-index: 1000;
  .item {
    display: block;
    width: 150px;
    height: 150px;
    border-radius: 15px;
    overflow: hidden;
    img {
      width: 100%;
      height: 100%;
    }
  }
  .item:not(:first-child) {
    margin-top: 30px;
  }
}
</style>